import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = a < b? a:b;
        int maxComDiv = 0;
        for(int i = 1; i <= c; i++){
            if(a % i == 0 && b % i == 0){
                maxComDiv = i;
            }
        }
        System.out.println(maxComDiv);
    }
}
